use crate::engine::Task;
use std::collections::VecDeque;

// TODO: 根据 spider 的 name 维护不同的 queue
pub struct Scheduler<ItemType: Clone> {
    pub queue: VecDeque<Task<ItemType>>,
}

impl<ItemType: Clone> Scheduler<ItemType> {
    pub fn new() -> Self {
        Self {
            queue: VecDeque::new(),
        }
    }

    pub fn enqueue(&mut self, task: Task<ItemType>) {
        self.queue.push_back(task);
    }

    pub fn dequeue(&mut self) -> Option<Task<ItemType>> {
        self.queue.pop_front()
    }
}
